package com.yowasa.xiuxian.engine.battle.enemy.strategy;

import com.google.common.collect.Lists;
import com.yowasa.xiuxian.annoations.BS;
import com.yowasa.xiuxian.constant.XiuxianConstants;
import com.yowasa.xiuxian.engine.battle.strategy.BaseSpellStrategy;
import com.yowasa.xiuxian.entity.bo.battle.BattleContent;
import com.yowasa.xiuxian.entity.bo.battle.UserBattleContent;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.ElementEnum;
import com.yowasa.xiuxian.exception.HandlerException;
import com.yowasa.xiuxian.service.helper.BattleHelper;
import com.yowasa.xiuxian.util.RandomUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@BS(name = "漂浮灵")
@Order(1006)
@Component
public class PiaoFuLing extends BaseSpellStrategy {
    @Autowired
    private BattleHelper battleHelper;

    @Override
    public ElementEnum getElement() {
        return null;
    }

    @Override
    public void action(UserBattleContent first, UserBattleContent second, BattleContent content) {
        int dmg;
        String desc;

        int orgAtk = first.getBattleInfo().getSpell();
        int def = second.getBattleInfo().getRes();
        int atk = (int) (orgAtk * 2.5);
        dmg = battleHelper.calAtk(atk, def);
        //user.getElement().get("土") < XiuxianConstants.DEFAULT_ELEMENT_ACTIVITY
        if(first.getUserBO().getElement().get("火") > XiuxianConstants.DEFAULT_ELEMENT_ACTIVITY){
            desc = RandomUtil.choice(Lists.newArrayList("花火之章","花火华卷","浮游火花","怒焰"));
        }else if(first.getUserBO().getElement().get("水") > XiuxianConstants.DEFAULT_ELEMENT_ACTIVITY){
            desc = RandomUtil.choice(Lists.newArrayList("浮游水弹","若水之章","冰晶狙击","寒冰华卷","怒焰"));
        }else if(first.getUserBO().getElement().get("金") > XiuxianConstants.DEFAULT_ELEMENT_ACTIVITY){
            desc = RandomUtil.choice(Lists.newArrayList("落雷","追踪雷球","紫电之章","紫电华卷"));
        }else if(first.getUserBO().getElement().get("木") > XiuxianConstants.DEFAULT_ELEMENT_ACTIVITY){
            desc = RandomUtil.choice(Lists.newArrayList("附着草种","种子风暴","草木绘卷","怒焰"));
        }else if(first.getUserBO().getElement().get("土") > XiuxianConstants.DEFAULT_ELEMENT_ACTIVITY){
            desc = RandomUtil.choice(Lists.newArrayList("浮游岩标","超级头锤","磐岩的鸣声","磐岩之章"));
        }else {
            desc = "殉爆";
        }
        battleHelper.autoAction(this, first, second, content, dmg, desc);
    }

    @Override
    public void limit(UserBO user) {
        throw new HandlerException("无法学习妖兽的攻击手段");
    }

    @Override
    public String limitDesc() {
        return "无";
    }

    @Override
    public String desc() {
        return  "高浓度的元素孕育而生的魔物，能够飘浮在空中。\n" +
                "飘浮灵在翅叶闭合时会拟态成某种植物果实的样子。因此在一些古老的传说中，它们被当作天上巨木结出的果实，被认为有着神奇的药用价值。\n\n" +
                "擅长法术攻击,不同的元素沾染会拥有不同的技能组\n" ;
    }


}
